<template>
  <div>
    <h3 class="title">App组件</h3>
    <button @click="getChild">父获取child组件中的数据</button>
    <hr />
    <child />
  </div>
</template>

<script>
import child from './components/child.vue'
export default {
  components: {
    child
  },
  data() {
    return {
      title: 'parent'
    }
  },
  methods: {
    getChild() {
      console.log(this.$root);
      // console.log(this.$children);
      // console.log(this.$children[0].title);
      this.$children.forEach(node => {
        // console.log(node?.title)
        console.log(node.title && node.title)
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
